Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete agents by agent id #324

Merged
merged 4 commits into from
Jan 20, 2025
Merged

Delete agents by agent id #324

merged 4 commits into from
Jan 20, 2025

Conversation

aaravpandya
Copy link
Collaborator

This PR introduces feature to delete agents by their agent id.

To use this feature, you can call sim.deleteAgents(world_to_agent_dict). The dict structure is {world_idx: [agent_ids]}. Sample code:

sim.deleteAgents({0: [1408]}) # delete agent id 1408 in world idx 0

We set an array deletedAgents with agent ids. We reuse functionality of setMaps where we destroy all agents and reinitialize them. But we ignore the agents specified in deletedAgents. So the agents are not initialized. Remember, because of this the indexing will change. For eg an agent at idx 5 will be at idx 4 after an agent is deleted.

Also, the deletedAgents array is permanent. You can reset this tensor with -1 values to reinitialize all the agents again. However, I reset the deletedAgents array when you call setMaps to change the map on runtime because the agent ids will have changed.

@daphne-cornelisse daphne-cornelisse changed the base branch from main to dev January 20, 2025 14:37
@daphne-cornelisse daphne-cornelisse changed the base branch from dev to dc/selfplay_safe January 20, 2025 14:37
@daphne-cornelisse daphne-cornelisse changed the base branch from dc/selfplay_safe to dev January 20, 2025 14:38
@daphne-cornelisse daphne-cornelisse merged commit a713a83 into dev Jan 20, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants